package cn.edu.zafu.bigdata.smj.a;

class InvalidScoreException extends Exception{
    public InvalidScoreException(String msg) {
        super(msg);
    }
}
public class scoreCheck {
    public static void checkScore(int score) throws InvalidScoreException{
        if (score < 0 || score > 100) {
            throw new InvalidScoreException("分数必须在0到100之间。");
        }
        System.out.println("分数有效。");
    }
    public static void main(String[] args) {
        int score = getIntFromUser();
        try {
            // 调用checkScore方法并传入用户输入的分数
            checkScore(score);
        } catch (InvalidScoreException e) {
            System.out.println("错误: " + e.getMessage());
        }
    }
    private static int getIntFromUser() {
        java.util.Scanner scanner = new java.util.Scanner(System.in);
        System.out.print("请输入分数: ");
        int score = scanner.nextInt();
        scanner.close();
        return score;
    }

}